home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 17 / MacFormat 17 (Spain) / MacFormat 17.bin / DATABASE / SHARED.DIR / 01006.ls < prev    next >
Encoding:
Text File  |  1996-03-14  |  14.6 KB  |  474 lines

  1. on InitData
  2.   global gFullCuttings, gMaxLines, gCurIndex, gName, gMakerName, gWorld, gSeenMaps, mpath, gHeadlocH, gNameLoch, gNameLocv, gMakerNum, gQTpath, gSoundpath, gTotalChapters, gMaxNuggets, gnuggets, gWhichNugget, gNuggetList, gNuggetOn, gNameCastnum, gInAMap, gNuggetDelay, gNuggetTime, gTrapStart
  3.   updateStage()
  4.   set gInAMap to 0
  5.   set gTrapStart to 0
  6.   sound stop 1
  7.   sound stop 2
  8.   set the keyDownScript to "CheckPrint"
  9.   InitDataGlobals()
  10.   set gMakerNum to value(gMakerNum)
  11.   set gMakerName to line gMakerNum of field "Makernumlist"
  12.   set name to gMakerName
  13.   set the text of field "ArticleNumber" to string(gMakerNum)
  14.   set gSeenMaps to 0
  15.   startTimer()
  16.   set gMaxLines to 18
  17.   set the itemDelimiter to "#"
  18.   set gMaxNuggets to the number of items in gnuggets
  19.   set the itemDelimiter to ","
  20.   set gWhichNugget to random(gMaxNuggets)
  21.   set gNuggetList to [gWhichNugget]
  22.   set gNuggetOn to 0
  23.   set gNuggetDelay to 15 * 60
  24.   set gNuggetTime to the ticks
  25.   put "loading script file and parsing it took: " && the timer && "ticks"
  26.   puppetSprite(10, 1)
  27.   set the castNum of sprite 10 to the number of cast (gMakerNum & "-head")
  28.   if gWorld = "Power" then
  29.     set the locV of sprite 10 to 101
  30.     set the locH of sprite 10 to 42
  31.     set gHeadlocH to 42
  32.   else
  33.     if gWorld = "Senses" then
  34.       set the locV of sprite 10 to 39
  35.       set the locH of sprite 10 to 38
  36.       set gHeadlocH to 38
  37.     else
  38.       if gWorld = "mind" then
  39.         set the locV of sprite 10 to 53
  40.         set the locH of sprite 10 to 41
  41.         set gHeadlocH to 41
  42.       else
  43.         if gWorld = "discover" then
  44.           set the locH of sprite 10 to 35
  45.           set the locV of sprite 10 to 85
  46.           set gHeadlocH to 35
  47.         else
  48.           if gWorld = "body" then
  49.             set the locV of sprite 10 to 61
  50.             set the locH of sprite 10 to 47
  51.             set gHeadlocH to 47
  52.           else
  53.             set the locV of sprite 10 to 53
  54.             set the locH of sprite 10 to 42
  55.             set gHeadlocH to 42
  56.           end if
  57.         end if
  58.       end if
  59.     end if
  60.   end if
  61.   puppetSprite(4, 1)
  62.   set gNameCastnum to the number of cast (gMakerNum & ".name")
  63.   set the castNum of sprite 4 to gNameCastnum
  64.   if gWorld = "Power" then
  65.     set the locH of sprite 4 to 151
  66.     set the locV of sprite 4 to 24
  67.   else
  68.     if gWorld = "Design" then
  69.       set the locH of sprite 4 to 137
  70.       set the locV of sprite 4 to 96
  71.       set gNameLoch to 137
  72.       set gNameLocv to 96
  73.     else
  74.       if gWorld = "Mind" then
  75.         set the locH of sprite 4 to 244
  76.         set the locV of sprite 4 to 68
  77.       else
  78.         if gWorld = "discover" then
  79.           if gNameCastnum > 0 then
  80.             set the locH of sprite 4 to the width of cast gNameCastnum / 2
  81.           end if
  82.           set the locV of sprite 4 to 20
  83.         else
  84.           if gWorld = "body" then
  85.             set the locH of sprite 4 to 360
  86.             set the locV of sprite 4 to 11
  87.           else
  88.             if gWorld = "Senses" then
  89.               set the locH of sprite 4 to 172
  90.               set the locV of sprite 4 to 19
  91.               set gNameLoch to 172
  92.               set gNameLocv to 19
  93.             end if
  94.           end if
  95.         end if
  96.       end if
  97.     end if
  98.   end if
  99.   updateStage()
  100.   if the machineType = 256 then
  101.     openXLib(the pathName & "fileio.dll")
  102.   end if
  103.   set cuname to "CU" & gMakerNum
  104.   set obj to FileIO(mnew, "read", mpath & cuname & ".TXT")
  105.   if objectp(obj) then
  106.     set gFullCuttings to obj(mReadFile)
  107.     obj(mdispose)
  108.     delete line the number of lines in gFullCuttings of gFullCuttings
  109.   else
  110.     alert("Error opening " && cuname & ".TXT")
  111.     set forcd to 0
  112.     if forcd = 1 then
  113.       ReturnToWorld()
  114.     else
  115.       abort()
  116.       go(2)
  117.     end if
  118.   end if
  119.   if the machineType = 256 then
  120.     closeXLib(the pathName & "fileio.dll")
  121.   end if
  122.   set cuttingindexcast to the number of cast ("CuttingIndex" & gWorld)
  123.   set tmp to Bsearch(gMakerName, cuttingindexcast)
  124.   set gCurIndex to line tmp of field cuttingindexcast
  125.   if the machineType < 256 then
  126.     openXLib(the pathName & "FixPalette")
  127.     set obj to FixPalette(mnew, 0, 0, 640, 480)
  128.     obj(mPatchIt)
  129.     obj(mdispose)
  130.     closeXLib(the pathName & "FixPalette")
  131.   end if
  132.   set num to count(gChapters)
  133.   set the text of field "chaptertitles" to "INTRODUCTION"
  134.   repeat with i = 2 to num
  135.     put getAt(gChapters, i) into line i of field "chaptertitles"
  136.   end repeat
  137.   set the text of field "CurrentArticle" to " "
  138.   set the text of field "CurrentChapter" to " "
  139.   set the visible of sprite 35 to 0
  140.   set the visible of sprite 36 to 0
  141.   set the visible of sprite 19 to 0
  142.   set the visible of sprite 20 to 0
  143.   NavButtonWindow()
  144.   UnBlackScreen()
  145.   sound playFile 1, gSoundpath & "S" & gMakerNum
  146.   put "initializing the database took:" && the timer && "ticks"
  147. end
  148.  
  149. on GoChapter num
  150.   global gChapters, gTitles, gArticles, gDates, gCaptions, gCurChap, gCurArticle
  151.   set numchaps to count(gChapters)
  152.   put "gochap " && num
  153.   if num > (numchaps + 1) then
  154.     exit
  155.   end if
  156.   if num < 1 then
  157.     exit
  158.   end if
  159.   unpuppet("4,10")
  160.   if num = (numchaps + 1) then
  161.   else
  162.     set gCurChap to num
  163.     set gCurArticle to 1
  164.     GoArticle()
  165.   end if
  166. end
  167.  
  168. on GoFlyingFacts
  169.   global gnuggets, gWorld, gNameLoch, gNameLocv, gNameCastnum, gHeadlocH, gMakerNum, gFlyingFacts, gArticlePage, gTextPages, gMaxLines
  170.   set namesprite to 4
  171.   set headsprite to 10
  172.   if (gWorld = "design") and (the frameLabel = "cutting") then
  173.     set the locH of sprite namesprite to 1000
  174.     set the castNum of sprite namesprite to gNameCastnum
  175.   end if
  176.   set the locH of sprite headsprite to gHeadlocH
  177.   set gFlyingFacts to " "
  178.   set the itemDelimiter to "@"
  179.   set tmpnugget to item gMakerNum of field ("makernugget" & (gMakerNum / 20) + 1)
  180.   set the itemDelimiter to "#"
  181.   set num to the number of items in tmpnugget
  182.   repeat with i = 1 to num
  183.     put item i of tmpnugget & RETURN after gFlyingFacts
  184.   end repeat
  185.   delete char 1 of gFlyingFacts
  186.   delete line 1 of gFlyingFacts
  187.   if the last line in gFlyingFacts = EMPTY then
  188.     delete char -30003 of gFlyingFacts
  189.   end if
  190.   set the itemDelimiter to ","
  191.   if gWorld = "Power" then
  192.     set gMaxLines to 19
  193.   else
  194.     if gWorld = "Senses" then
  195.       set gMaxLines to 25
  196.     else
  197.       if gWorld = "body" then
  198.         set gMaxLines to 22
  199.       else
  200.         set gMaxLines to 20
  201.       end if
  202.     end if
  203.   end if
  204.   set the text of field "flyingfacts" to line 1 to gMaxLines of gFlyingFacts
  205.   set numlines to the number of lines in gFlyingFacts
  206.   set tmppages to numlines / gMaxLines
  207.   if (tmppages * gMaxLines) = numlines then
  208.     set gTextPages to tmppages
  209.   else
  210.     set gTextPages to tmppages + 1
  211.   end if
  212.   set gArticlePage to 1
  213.   go("facts")
  214.   if (gWorld = "Senses") or (gWorld = "Design") then
  215.     set the locH of sprite namesprite to gNameLoch
  216.     set the locV of sprite namesprite to gNameLocv
  217.   end if
  218.   set the text of field "currentchapter" to "FLYING FACTS"
  219.   set the text of field "currentarticle" to "1/1"
  220.   set the visible of sprite 35 to 0
  221.   set the visible of sprite 36 to 0
  222.   set the visible of sprite 19 to 0
  223.   if the number of lines in gFlyingFacts > gMaxLines then
  224.     set the visible of sprite 20 to 1
  225.   else
  226.     set the visible of sprite 20 to 0
  227.   end if
  228. end
  229.  
  230. on NameToNum name
  231.   set num to Bsearch(name, "MakerList")
  232.   return value(item 2 of line num of field "MakerList")
  233. end
  234.  
  235. on InitDataGlobals
  236.   global gdelim, gWorld, mpath, gMakerName, gMakerNum, gSoundpath, gQTpath, gDrive, gQTbuttons, gMakersPath, gQTAnimpath, gClickSndCast
  237.   set gClickSndCast to the number of cast "click"
  238.   put the number of cast "qtplay" into item 1 of gQTbuttons
  239.   put the number of cast "qtstop" into item 2 of gQTbuttons
  240.   if the machineType <> 256 then
  241.     set gdelim to ":"
  242.     set the itemDelimiter to gdelim
  243.     set gDrive to item 1 of the pathName
  244.     set the itemDelimiter to ","
  245.   else
  246.     set gdelim to "\"
  247.     set the itemDelimiter to gdelim
  248.     set gDrive to item 1 of the pathName
  249.     set the itemDelimiter to ","
  250.   end if
  251.   set the itemDelimiter to "."
  252.   set gWorld to item 1 of the movieName
  253.   set the itemDelimiter to ","
  254.   set mpath to the pathName & gWorld & gdelim
  255.   set gSoundpath to gDrive & gdelim & "SOUNDDB" & gdelim
  256.   set gQTpath to gDrive & gdelim & "QTDB" & gdelim
  257.   set gQTAnimpath to gDrive & gdelim & "QTANIM" & gdelim
  258.   set gMakersPath to gDrive & gdelim & "MAKERS" & gdelim
  259.   set gMakerName to word 1 of line value(gMakerNum) of field "MakerNumList"
  260. end
  261.  
  262. on AdjustText txt, maxlines
  263.   set numlines to the number of lines in txt
  264.   set numpages to numlines / maxlines
  265.   if (numpages * numlines) < numlines then
  266.     set numpages to numpages + 1
  267.   end if
  268.   repeat with i = 1 to numpages
  269.     if line ((i - 1) * maxlines) + 1 of txt = RETURN then
  270.       delete line ((i - 1) * maxlines) + 1 of txt
  271.     end if
  272.     if line (i * maxlines) - 1 of txt = RETURN then
  273.       set tmp to line i * maxlines to numlines of txt
  274.       delete line i * maxlines to numlines of txt
  275.       put RETURN into line i * maxlines of txt
  276.       put RETURN & tmp after txt
  277.     end if
  278.   end repeat
  279.   return txt
  280. end
  281.  
  282. on FillText txt, fnt, sz, width
  283.   return txt
  284. end
  285.  
  286. on MoveArticle dir
  287.   global gCurArticle, gArticles, gCurChap, gMakerNum
  288.   set num to count(getAt(gArticles, gCurChap))
  289.   if dir = "prev" then
  290.     if gCurArticle > 1 then
  291.       set gCurArticle to gCurArticle - 1
  292.     else
  293.       set gCurArticle to num
  294.     end if
  295.     if (gMakerNum = 10) and (gCurChap = 2) and (gCurArticle = 3) then
  296.       set gCurArticle to 2
  297.     end if
  298.     if (gMakerNum = 39) and (gCurChap = 2) and (gCurArticle = 2) then
  299.       set gCurArticle to 1
  300.     end if
  301.   else
  302.     if gCurArticle < num then
  303.       set gCurArticle to gCurArticle + 1
  304.     else
  305.       set gCurArticle to 1
  306.     end if
  307.     if (gMakerNum = 10) and (gCurChap = 2) and (gCurArticle = 3) then
  308.       set gCurArticle to 4
  309.     end if
  310.     if (gMakerNum = 39) and (gCurChap = 2) and (gCurArticle = 2) then
  311.       set gCurArticle to 3
  312.     end if
  313.   end if
  314.   NavButtonUpdate()
  315.   GoArticle()
  316. end
  317.  
  318. on ScrollPage dir
  319.   global gArticlePage, gCurCutting, gFormattedText, gTextPages, gMaxLines, gWorld, gCurChap, gPicLoch, gFlyingFacts, gMakerNum
  320.   set picsprite to 3
  321.   set cuttingsprite to 6
  322.   if (the frameLabel contains "partwork") and (gArticlePage = 1) then
  323.     set gPicLoch to the locH of sprite picsprite
  324.   end if
  325.   if dir = "back" then
  326.     if gArticlePage > 1 then
  327.       set gArticlePage to gArticlePage - 1
  328.     else
  329.       set gArticlePage to gTextPages
  330.     end if
  331.   else
  332.     if dir = "next" then
  333.       if gArticlePage < gTextPages then
  334.         set gArticlePage to gArticlePage + 1
  335.       else
  336.         set gArticlePage to 1
  337.       end if
  338.     end if
  339.   end if
  340.   if the frameLabel contains "cutting" then
  341.     set the text of field "cutting" to line ((gArticlePage - 1) * gMaxLines) + 1 to gArticlePage * gMaxLines of gFormattedText
  342.   else
  343.     if the frameLabel = "facts" then
  344.       set the text of field "flyingfacts" to line ((gArticlePage - 1) * gMaxLines) + 1 to gArticlePage * gMaxLines of gFlyingFacts
  345.     else
  346.       if the frameLabel contains "partwork" then
  347.         if (gArticlePage = 1) and (gWorld = "Power") and (gCurChap = 1) then
  348.           set the text of field "partwork" to " "
  349.           if gMakerNum = 119 then
  350.             go("partwork.MAT")
  351.           else
  352.             go("partwork")
  353.           end if
  354.           puppetSprite(cuttingsprite, 1)
  355.           set cuttingloch to the locH of sprite cuttingsprite
  356.           set the locH of sprite cuttingsprite to 1000
  357.           updateStage()
  358.           set the locH of sprite picsprite to gPicLoch
  359.           set the text of field "partwork" to line ((gArticlePage - 1) * gMaxLines) + 1 to gArticlePage * gMaxLines of gFormattedText
  360.           set the locH of sprite cuttingsprite to cuttingloch
  361.           puppetSprite(cuttingsprite, 0)
  362.           updateStage()
  363.         else
  364.           if gCurChap > 1 then
  365.             if gMakerNum = 119 then
  366.               go("innerpartwork.MAT")
  367.             else
  368.               go("innerpartwork")
  369.             end if
  370.             set the text of field "partwork2" to line ((gArticlePage - 1) * gMaxLines) + 1 to gArticlePage * gMaxLines of gFormattedText
  371.           else
  372.             set the locH of sprite picsprite to 1000
  373.             if gMakerNum = 119 then
  374.               go("partwork2.MAT")
  375.             else
  376.               go("partwork2")
  377.             end if
  378.             set the text of field "partwork2" to line ((gArticlePage - 1) * gMaxLines) + 1 to gArticlePage * gMaxLines of gFormattedText
  379.           end if
  380.         end if
  381.       end if
  382.     end if
  383.   end if
  384.   set forwardbutton to 20
  385.   set backbutton to 19
  386.   if gArticlePage > 1 then
  387.     set the visible of sprite backbutton to 1
  388.   else
  389.     set the visible of sprite backbutton to 0
  390.   end if
  391.   if gArticlePage = gTextPages then
  392.     set the visible of sprite forwardbutton to 0
  393.   else
  394.     set the visible of sprite forwardbutton to 1
  395.   end if
  396.   EndTrapMouse()
  397. end
  398.  
  399. on SetVolume
  400.   global gWorld
  401.   set volsprite to 37
  402.   set level to the soundLevel
  403.   puppetSprite(volsprite, 1)
  404.   if the frameLabel = "qt" then
  405.     set the castNum of sprite volsprite to the number of cast ("vol" & level)
  406.   end if
  407. end
  408.  
  409. on VolumeDrag dir
  410.   global gWorld
  411.   set me to the clickOn
  412.   if not (the puppet of sprite me) then
  413.     puppetSprite(me, 1)
  414.   end if
  415.   set oldlevel to the soundLevel
  416.   if the paramCount = 0 then
  417.     if gWorld = "mind" then
  418.       set bottom to 35
  419.     else
  420.       set bottom to 25
  421.     end if
  422.     set inc to (the height of sprite me - bottom) / 7
  423.     repeat while the mouseDown
  424.       set mv to the mouseV
  425.       set v to mv - the top of sprite me
  426.       set level to 8 - (v / inc)
  427.       if level > 7 then
  428.         set level to 7
  429.       else
  430.         if level < 0 then
  431.           set level to 0
  432.         end if
  433.       end if
  434.       if oldlevel <> level then
  435.         set the soundLevel to level
  436.         set oldlevel to level
  437.       end if
  438.       updateStage()
  439.       if (gWorld = "body") and (the frameLabel = "cutting") then
  440.         set the castNum of sprite me to the number of cast ("volb" & level)
  441.         next repeat
  442.       end if
  443.       set the castNum of sprite me to the number of cast ("vol" & level)
  444.     end repeat
  445.   else
  446.     if dir = "horizontal" then
  447.       set bottom to 25
  448.       set inc to (the width of sprite me - bottom) / 7
  449.       repeat while the mouseDown
  450.         set mh to the mouseH
  451.         set h to the right of sprite me - mh
  452.         set level to 8 - (h / inc)
  453.         if level > 7 then
  454.           set level to 7
  455.         else
  456.           if level < 0 then
  457.             set level to 0
  458.           end if
  459.         end if
  460.         if oldlevel <> level then
  461.           set the soundLevel to level
  462.           set oldlevel to level
  463.         end if
  464.         updateStage()
  465.         if gWorld = "body" then
  466.           set the castNum of sprite me to the number of cast ("volb" & level)
  467.           next repeat
  468.         end if
  469.         set the castNum of sprite me to the number of cast ("vol" & level)
  470.       end repeat
  471.     end if
  472.   end if
  473. end
  474.